package cn.yuanqiao.web.controller.archive.danganzhengli;

import cn.yuanqiao.archive.danganzhengli.service.IDanganzhengliService;
import cn.yuanqiao.archive.danganzhengli.utils.OfdAgent;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zjj
 * @date 2023/7/5
 */
@RestController
@RequestMapping("/archive/dazl")
public class DanganzhengliController extends BaseController {

    @Autowired
    private IDanganzhengliService danganzhengliService;

    @Autowired
    private OfdAgent ofdAgent;

    @Value("${FBswitch}")
    private boolean fbSwitch;

    /**
     * 退回
     * @return
     */
    @Log(title = "档案整理退回", businessType = BusinessType.UPDATE)
    @PostMapping("/tuihui")
    public AjaxResult tuihui(@RequestParam("categoryId") Long categoryId,@RequestParam("ids") Long [] ids){
        danganzhengliService.tuihui(categoryId,ids);
        return AjaxResult.success();
    }

    @Log(title = "查询fb状态", businessType = BusinessType.SELECT)
    @PostMapping("/fb/stat")
    public AjaxResult fbstat(){
        return AjaxResult.success(fbSwitch);
    }

    @GetMapping("/zh")
    public AjaxResult zh()throws Exception{
        List<File> fileList = new ArrayList<>();
        fileList.add(new File("C:\\Users\\Administrator\\Desktop\\导入测试文件\\新建 DOCX 文档.docx"));
        ofdAgent.officesToOfd(fileList,"C:\\Users\\Administrator\\Desktop\\导入测试文件\\新建 DOCX 文档.ofd");
        //fileList.add(new File("C:\\Users\\Administrator\\Desktop\\导入测试文件\\bg-login.jpg"));
        //ofdAgent.imageToOFD(fileList,"C:\\Users\\Administrator\\Desktop\\导入测试文件\\bg-login.ofd");
        return AjaxResult.success();
    }

    /**
     * 中铁
     * 项目下的卷层
     * 退回
     * @return
     */
    @Log(title = "项目下的卷层退回", businessType = BusinessType.UPDATE)
    @PostMapping("/tuihuiAnJuan")
    public AjaxResult tuihuiAnJuan(@RequestParam("categoryId") Long categoryId,@RequestParam("ids") Long [] ids){
        danganzhengliService.tuihuiAnJuan(categoryId,ids);
        return AjaxResult.success();
    }

}
